package main

import (
	"fmt"
	"gopkg.in/yaml.v2"
	"io/ioutil"
)

func main() {
	bytes, err := ioutil.ReadFile("yaml/hello.yaml")
	if err != nil {
		fmt.Println("error.", err)
		return
	}
	config := Config{Server:Server{Port: 8888, Name: "kplight"}}
	out, err := yaml.Marshal(&config)
	fmt.Println("out=", string(out))
	err = yaml.Unmarshal(bytes, &config)
	if err != nil {
		fmt.Println("error2", err)
		return
	}
	fmt.Println("config=", config)
}

type Config struct {
	Server Server `yaml:"server"`
}

type Server struct {
	Port int32	`yaml:"port"`
	Name string `yaml:"name"`
}
